﻿using System;
using K9Nano.Remoting;

namespace K9Nano.Events
{
    [Serializable]
    public class EventDataWrapper
    {
        public string Name { get; set; }
        public IEventData Data { get; set; }

        public EventDataWrapper()
        {
        }

        public EventDataWrapper(string eventName, IEventData eventData, IApiInfo source)
        {
            Name = eventName;
            eventData.EventSource = string.IsNullOrWhiteSpace(eventData.EventSource)
                ? source.Name
                : $"{source.Name}.{eventData.EventSource}";
            Data = eventData;
        }

        public override string ToString()
        {
            return $"{Name}@{Data.EventSource}";
        }
    }
}